﻿
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/17/2013 17:10:12
-- Generated from EDMX file: E:\gits\RBSFPP\src\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_MEMBERSHIP];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/17/2013 17:30:18
-- Generated from EDMX file: E:\gits\RBSFPP\src\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Accounts] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Accounts]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Accounts];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/17/2013 23:15:33
-- Generated from EDMX file: E:\gits\RBSFPP\src\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/18/2013 00:40:35
-- Generated from EDMX file: E:\gits\RBSFPP\src\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/15/2014 00:01:16
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/17/2014 18:25:01
-- Generated from EDMX file: E:\gits\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPredict]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Predicts] DROP CONSTRAINT [FK_ProductPredict];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorPredict]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Predicts] DROP CONSTRAINT [FK_FactorPredict];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO

IF OBJECT_ID(N'[dbo].[Predicts]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Predicts];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/17/2014 18:26:43
-- Generated from EDMX file: E:\gits\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/17/2014 18:26:43
-- Generated from EDMX file: E:\gits\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/17/2014 18:31:00
-- Generated from EDMX file: E:\gits\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/17/2014 19:06:02
-- Generated from EDMX file: E:\gits\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/18/2014 14:13:52
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/18/2014 19:46:27
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/18/2014 19:49:14
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/22/2014 16:49:39
-- Generated from EDMX file: E:\gits\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/24/2014 20:02:03
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductPricingPerUnitTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductPricingPerUnitTrackings] DROP CONSTRAINT [FK_ProductProductPricingPerUnitTracking];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnitTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnitTrackings];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/25/2014 18:45:32
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductPricingPerUnitTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductPricingPerUnitTrackings] DROP CONSTRAINT [FK_ProductProductPricingPerUnitTracking];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnitTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnitTrackings];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/25/2014 19:08:06
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductPricingPerUnitTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductPricingPerUnitTrackings] DROP CONSTRAINT [FK_ProductProductPricingPerUnitTracking];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnitTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnitTrackings];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/26/2014 00:01:06
-- Generated from EDMX file: D:\git\rbsfpp\KKU.RBSFPP\KKU.RBSFPP.Shared\Shared\DAC\RBSFPPModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO

USE [KKU_RBSFPP_Database];
GO

IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PrivilegeLevelAccount]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Members] DROP CONSTRAINT [FK_PrivilegeLevelAccount];
GO

IF OBJECT_ID(N'[dbo].[FK_CategoryProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProduct]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_ProductPricingPerUnitProduct];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductPricingPerUnitProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_ProductPricingPerUnitProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_MemberProductTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductTrackings] DROP CONSTRAINT [FK_MemberProductTracking];
GO

IF OBJECT_ID(N'[dbo].[FK_FactorFactorValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FactorValues] DROP CONSTRAINT [FK_FactorFactorValue];
GO

IF OBJECT_ID(N'[dbo].[FK_ProductProductPricingPerUnitTracking]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProductPricingPerUnitTrackings] DROP CONSTRAINT [FK_ProductProductPricingPerUnitTracking];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Members]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Members];
GO

IF OBJECT_ID(N'[dbo].[PrivilegeLevels]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivilegeLevels];
GO

IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Categories];
GO

IF OBJECT_ID(N'[dbo].[ProductUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductUnits];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnits];
GO

IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO

IF OBJECT_ID(N'[dbo].[ProductTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductTrackings];
GO

IF OBJECT_ID(N'[dbo].[Factors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Factors];
GO

IF OBJECT_ID(N'[dbo].[FactorValues]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FactorValues];
GO

IF OBJECT_ID(N'[dbo].[ProductPricingPerUnitTrackings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProductPricingPerUnitTrackings];
GO


-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO
